package com.myschool;

import java.util.*;

public class GradeComp implements Comparator
{
    public int compare(Object o1, Object o2)
    {
        Student s1, s2;
        if(!(o1 instanceof Student) || !(o2 instanceof Student))
        {
            throw new IllegalArgumentException();
        }
        else
        {
            s1 = (Student) o1;
            s2 = (Student) o2;
            if (s1.getGPA() == s2.getGPA())
                return 0;
            else if(s1.getGPA() < s2.getGPA())
            {
                return -1;
            }
            else
            {
                return 1;
            }
        }        
    }
}
